#include <stdio.h>
#include <string.h>

#define MAX 1000

int main(int argc, char *argv[])
{
	int n, len[MAX], d[MAX];
	int i, j, it;
	char id[MAX][10];
	char ct[10];

	scanf("%d", &n);
	for (i=0; i<n; i++) {
		scanf("%d %d %s", &len[i], &d[i], id[i]);
	}

	for (i=0; i<n-1; i++) {
		for (j=i+1; j<n; j++) {
			if ((len[i] < len[j]) ||
				(len[i] == len[j] && d[i] > d[j]) ||
				(len[i] == len[j] && d[i] == d[j] && strcmp(id[i], id[j]) < 0)) {
				it = len[i]; len[i] = len[j]; len[j] = it;
				it = d[i]; d[i] = d[j]; d[j] = it;
				strcpy(ct, id[i]); strcpy(id[i], id[j]); strcpy(id[j], ct);
			}
		}
	}

	printf("%s\n", id[0]);

	return 0;
}
